package com.copa.provider.music.kugou;

import com.copa.api.MusicApi;
import com.copa.entity.Music;

import java.io.IOException;
import java.util.List;

/**
 * @author copa
 * @createDate 2022-02-22 15:29
 * @function
 */
public class KugouMusicApi implements MusicApi {

    @Override
    public List<Music> searchMusicSync(String keyword, int page, boolean needLink) throws IOException {
        List<Music> result = new KugouSearchMusicRequest(keyword, page).requestSync();
        if (needLink) {
            // 需要下载歌曲，直接跳过下载页面
            result.forEach(music -> music.setJumpUrl(music.getMusicUrl()));
        }
        return result;
    }
}
